<div>
		<?if(isset($student_grades)):?>
		<p class="lead-title">Grades <a href="#" data-reveal-id="gradeTable" class="btn btn-mini">show grading table</a> 
		<?if($edit_grade):?>
		<span style="font-size:11px;border:1px solid #000;padding:5px;">Toggle Edit on/off <input type="checkbox" id="grades"></span>
			<small><i class="fa fa-info"></i>&nbsp; Fields are automatically being saved when out of focus. </small><?endif;?>
		</p>
			<table class="table table-compressed table-bordered">
				<tr class="info">
					<td colspan="2" style="font-weight:bold;">LEARNING AREAS</td>
						<?foreach($gp as $k=>$v):?>
							<td  style="font-weight:bold;"><?=strtoupper($v->gp_code);?></td>
						<?endforeach;?>
					<?if(strtolower($grade_type) === "smiley"):?>
					<?else:?>
						<td style="font-weight:bold;">FINAL</td>
					<?endif;?>
				</tr>
				
				<?if($student_grades):?>

					<? foreach ($student_grades as $key => $value):?>
						<tr id='<?=$value['sub_id'];?>'>

							<td colspan="2"><?=$value['name'];?></td>

							<?if($value['grades']):?>
								
								<? /* Grading Type is SMILEY */?>	
								<?if(strtolower($grade_type) === "smiley"):?>

									<?foreach($value['grades'] as $grading_p_id => $v):?>

										<?php if($grading_p_id == "final"){ continue; } // Skip Final, no final for kinder ?>

										<td>
											
											<?if(isset($edit_all_period) && $edit_all_period):?>
	
												<? /* Grades can only be edited during there current grading period */ ?>
												<?if($edit_grade):?>
												<?
													$attr = " class='pk_select ajax-change grades' grade_type='$sec->grade_type' level_code = '".strtolower($sec->level_code)."' orgval='{$v->value}' gp_id = '{$v->id}' href='javascript:;' url='".site_url('output/set_student_grades/'.__link($v->id))."'";
													echo _smiley_dropdown($v->value,'Select',$attr, $v->id);
												?>
													<input type="hidden" value="<?=$v->value?>" id="pk_hidden_<?=$v->id?>" >
													<span class="loading" style="display:inline-block;"></span>
												<?else:?>
													<?=_smiley($v->value);?>
												<?endif;?>

											<?else:?>

												<? /* Grades can only be edited during there current grading period */ ?>
												<?if($this->current_grading_period == $grading_p_id AND $edit_grade):?>
												<?
													$attr = " class='pk_select ajax-change grades' grade_type='$sec->grade_type' level_code = '".strtolower($sec->level_code)."' orgval='{$v->value}' gp_id = '{$v->id}' href='javascript:;' url='".site_url('output/set_student_grades/'.__link($v->id))."'";
													echo _smiley_dropdown($v->value,'Select',$attr, $v->id);
												?>
													<input type="hidden" value="<?=$v->value?>" id="pk_hidden_<?=$v->id?>" >
													<span class="loading" style="display:inline-block;"></span>
												<?else:?>
													<?=_smiley($v->value);?>
												<?endif;?>

											<?endif;?>
										</td>
									<?endforeach;?>
								
								<? /* Grading Type is NUMERIC */ ?>
								<?elseif(strtolower($grade_type) === "numeric"):?>
									
									<?$final_pass = 0; foreach($value['grades'] as $grading_p_id => $v):?>

										<td>

												<?if($grading_p_id === "final"): $final_pass++;?> <? /* Final Average Compute in the model */ ?>

													<div class="row">
															<div class="large-6 columns"><span class="badge badge-inverse"><?=$v;?></span></div>
															<div class="large-6 columns"><span class="badge badge-<?=_numeric_badge(floatval($v));?>"><?=_convert($v);?></span></div>
													</div>
												<?else:?>
													<?if(isset($edit_all_period) && $edit_all_period):?>
												
														<?if($edit_grade):?>
															<div class="row">
															  <div class="large-3 columns"><span class="badge badge-<?=_numeric_badge(floatval($v->value));?>"><?=_convert($v->value);?></span></div>
															  <div class="large-9 columns"><input style="width:90px;display:inline-block;margin:-1px;" type="text" value="<?=$v->value;?>" url="<?=site_url('output/set_student_grades/'.__link($v->id));?>" class="ajax-change grades numeric_grade class_txt_grade_<?=$key?>" gp_id = "<?=$v->id?>" sub_key="<?=$key?>" orgval="<?=$v->value;?>">
																			<span class="loading" style="display:inline-block;"></span></div>
															</div>
														<?else:?>
															<div class="btn-group">
															  <button tabindex="-1" class="btn btn-mini"><span class="badge badge-inverse"><?=$v->value;?></span></button>
															  <button tabindex="-1" class="btn btn-mini"><span class="badge badge-<?=_numeric_badge(floatval($v->value));?>"><?=_convert($v->value);?></span></button>
															</div>
														<?endif;?>

													<?else:?>
	
														<? /* Grades can only be edited during there current grading period */ ?>
														<?if($this->current_grading_period == $grading_p_id AND $edit_grade):?>
															<div class="row">
																<div class="large-3 columns"><span class="badge badge-<?=_numeric_badge(floatval($v->value));?>"><?=_convert($v->value);?></span></div>
																<div class="large-9 columns"><input style="width:90px;display:inline-block;margin:-1px;" type="text" value="<?=$v->value;?>" url="<?=site_url('output/set_student_grades/'.__link($v->id));?>" class="ajax-change grades numeric_grade class_txt_grade_<?=$key?>" gp_id = "<?=$v->id?>" sub_key="<?=$key?>" orgval="<?=$v->value;?>">
																	<span class="loading" style="display:inline-block;"></span></div>
															</div>
														<?else:?>
															<div class="btn-group">
															  <button tabindex="-1" class="btn btn-mini"><span class="badge badge-inverse"><?=$v->value;?></span></button>
															  <button tabindex="-1" class="btn btn-mini"><span class="badge badge-<?=_numeric_badge(floatval($v->value));?>"><?=_convert($v->value);?></span></button>
															</div>
														<?endif;?>

													<?endif;?>
												<?endif;?>

										</td>
									<?endforeach;?>

									<?if($final_pass <=0):?> <? /* EXtra TD */ ?>
										<td></td>
									<?endif;?>
									
								<?else:?>
									<td><p><i class="fa fa-warning"></i>&nbsp; No assigned grade type for this student year level.</p></td>

								<?endif;?>

							<?else:?>

							<?endif;?>
							
							<td><a tabindex="-1" class="ajax-del_subject" value="<?php echo $value['sub_id']; ?>" href="javascript:;" url="<?=site_url('output/del_student_grades/'.__link($value['sub_id'],$e_id));?>" title="Delete subject from student?" e_id = "<?=$e_id?>"><i class="icon-remove"></i></a><span class="loading" style="display:inline-block;"></span></td>
						</tr>
					<?endforeach;?>
				<?else:?>
					<tr>
						<td colspan="<?=count($value['grades'] + 2);?>">
							<div class="alert alert-danger"><i class="fa fa-warning"></i>&nbsp; Unable to create student grades. No subjects available in the curriculum for this student year level.</div>
						</td>
					</tr>
				<?endif;?>
			</table>
		<?else:?>
			<div class="alert-box">
				Please Select A Student to show grades
			</div>
		<?endif;?>
</div>

<!--REMARKS-->
<div>
	<?if(isset($remarks)):?>
		<p class="lead-title">Remarks 
			<?if($edit_remarks):?>
			<span style="font-size:11px;border:1px solid #000;padding:5px;">Toggle Edit on/off <input type="checkbox" id="remarks"></span>
			<small><i class="fa fa-info"></i>&nbsp; Fields are automatically being saved when out of focus. </small><?endif;?>
		</p>
		<table class="table table-bordered table-striped">
			<tbody>
				<tr class="success">
					<?if($gp):?>
						<?foreach($gp as $k => $v):?>
							<td width="<?=100/count($gp)?>%" ><strong><?=ucwords($v->gp_desc);?></strong></td>
						<?endforeach;?>
					<?else:?>
						<td colspan="5">-- Grading Periods --</td>
					<?endif;?>
				</tr>
					<?foreach($remarks as $rem):?>
						<tr>
							<?if($rem['remarks']):?>
								<?foreach($rem['remarks'] as $grading_p_id => $v):?>
									<td>
										
										<?if(isset($edit_all_period) && $edit_all_period):?>
											
											<?if($edit_remarks):?>
												<span class="loading"></span>
												<textarea class="ajax-change remarks" url="<?=site_url('output/advisory_remarks/'.__link($v->id));?>" style="max-width:100%;min-width:100%;min-height:220px;resize: none;padding:5px;font-size:14px;" orgval="<?=trim(html_entity_decode($v->remarks));?>"><?=trim(html_entity_decode($v->remarks));?></textarea>
											<?else:?>
												<p><?=trim(html_entity_decode($v->remarks));?></p>
											<?endif?>

										<?else:?>

											<? /* Grades can only be edited during there current grading period */ ?>
											<?if($this->current_grading_period == $grading_p_id AND $edit_remarks):?>
												<span class="loading"></span>
												<textarea class="ajax-change remarks" url="<?=site_url('output/advisory_remarks/'.__link($v->id));?>" style="max-width:100%;min-width:100%;min-height:220px;resize: none;padding:5px;font-size:14px;" orgval="<?=trim(html_entity_decode($v->remarks));?>"><?=trim(html_entity_decode($v->remarks));?></textarea>
											<?else:?>
												<p><?=trim(html_entity_decode($v->remarks));?></p>
											<?endif?>

										<?endif;?>
									</td>
								<?endforeach;?>
							<?else:?>
								<td colspan="<?=count($gp);?>"> <div class="alert alert-danger"><i class="fa fa-warning"></i>&nbsp; Unable to create student remarks either no grading period available or refresh the page to re-create them.</div></td>
							<?endif;?>
						</tr>
					<?endforeach;?>
			</tbody>
		</table>
	<?else:?>
		<div class="alert-box">Please Select to show remarks Student.</div>
	<?endif;?>
</div>

<!--ATTENDANCE-->
<div>
	<?if(isset($attendance)):?>
		<p class="lead-title">Attendance 
			<?if($edit_attendance):?>
				<span style="font-size:11px;border:1px solid #000;padding:5px;">
					Toggle Edit on/off 
				<input type="checkbox" id="attendance"></span>
				<small><i class="fa fa-info"></i>&nbsp; Fields are automatically being saved when out of focus. </small>
			<?endif;?>
		</p>
			<table class="table table-bordered table-stripped table-compressed">
				<tr class="info">
					<td>Term Attendance</td>
						<?foreach($gp as $k=>$v):?>
							<td  style="font-weight:bold;"><?=strtoupper($v->gp_code);?></td>
						<?endforeach;?>
					<td>Total</td>
				</tr>
					<tr>
						<td>Total No. of Days</td>
						<?$tot_no_day = 0; ?>
						<?foreach($attendance as $grading_p_id => $v):?>
							<?if(isset($v->generate)):?>
								<td><a href="<?=site_url('teacher/generate_attendance/'.$eid_hash.'/'.$hash);?>" class="btn btn-mini">Unable to generate attendance</a></td>
							<?else:?>
								<?$tot_no_day += $v->no_of_days;?>
								<td>
										
										<?if(isset($edit_all_period) && $edit_all_period):?>
											
											<?if($edit_attendance):?>
												<input class="ajax-change attendance attendance_input cls_no_day" kind="no_day" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/no_of_days/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->no_of_days));?>" value="<?=floatval($v->no_of_days);?>"><span class="loading" style="display:inline-block;"></span>
											<?else:?>
												<span class="badge badge-info"><?=floatval($v->no_of_days);?></span>
											<?endif;?>

										<?else:?>

											<?if($this->current_grading_period == $grading_p_id AND $edit_attendance):?>
												<input class="ajax-change attendance attendance_input cls_no_day" kind="no_day" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/no_of_days/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->no_of_days));?>" value="<?=floatval($v->no_of_days);?>"><span class="loading" style="display:inline-block;"></span>
											<?else:?>
												<span class="badge badge-info"><?=floatval($v->no_of_days);?></span>
											<?endif;?>

										<?endif;?>
	
								</td>
							<?endif;?>
							
						<?endforeach?>
						<td><div class="badge badge-info"><?=$tot_no_day;?></div></td>
					</tr>

					<tr>
						<td>Absent</td>
						<?$tot_absent = 0;?>
						<?foreach($attendance as $grading_p_id => $v):?>
							<?if(!isset($v->generate)):?>
								<?$tot_absent += $v->absent;?>
								<td>
		
									<?if(isset($edit_all_period) && $edit_all_period):?>
											
										<?if($edit_attendance):?>
											<input class="ajax-change attendance attendance_input cls_absent" kind="absent" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/absent/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->absent));?>" value="<?=floatval($v->absent);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge badge-important"><?=floatval($v->absent);?></span>
										<?endif;?>

									<?else:?>

										<?if($this->current_grading_period == $grading_p_id AND $edit_attendance):?>
											<input class="ajax-change attendance attendance_input cls_absent" kind="absent" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/absent/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->absent));?>" value="<?=floatval($v->absent);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge badge-important"><?=floatval($v->absent);?></span>
										<?endif;?>

									<?endif;?>
								</td>
							<?endif;?>
						<?endforeach?>
						<td><div class="badge badge-important"><?=$tot_absent;?></div></td>
					</tr>

					<tr>
						<td>Present</td>
						<?$tot_present = 0;?>
						<?foreach($attendance as $grading_p_id => $v):?>
						<?if(!isset($v->generate)):?>
						<?$tot_present += $v->present;?>
							<td>
									<?if(isset($edit_all_period) && $edit_all_period):?>
											
										<?if($edit_attendance):?>
												<input class="ajax-change attendance attendance_input cls_present" kind="present" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/present/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->present));?>" value="<?=floatval($v->present);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge-success"><?=floatval($v->present);?></span>
										<?endif;?>

									<?else:?>

										<?if($this->current_grading_period == $grading_p_id AND $edit_attendance):?>
											<input class="ajax-change attendance attendance_input cls_present" kind="present" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/present/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->present));?>" value="<?=floatval($v->present);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge badge-success"><?=floatval($v->present);?></span>
										<?endif;?>

									<?endif;?>
							</td>
						<?endif;?>
						<?endforeach?>
						<td><div class="badge badge-success"><?=$tot_present;?></div></td>
					</tr>

					<tr>
						<td>Tardy</td>
						<?$tot_tardy = 0;?>
						<?foreach($attendance as $grading_p_id => $v):?>
						<?if(!isset($v->generate)):?>
						<?$tot_tardy += $v->tardy;?>
							<td>
									<?if(isset($edit_all_period) && $edit_all_period):?>
											
										<?if($edit_attendance):?>
												<input class="ajax-change attendance attendance_input cls_tardy" kind="tardy" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/tardy/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->tardy));?>" value="<?=floatval($v->tardy);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge-warning"><?=floatval($v->tardy);?></span>
										<?endif;?>

									<?else:?>

										<?if($this->current_grading_period == $grading_p_id AND $edit_attendance):?>
											<input class="ajax-change attendance attendance_input cls_tardy" kind="tardy" type="text" style="width:100px;margin:0;display:inline-block;" url="<?=site_url('output/advisory_attendance/tardy/'.__link($v->id));?>" orgval="<?=trim(html_entity_decode($v->tardy));?>" value="<?=floatval($v->tardy);?>"><span class="loading" style="display:inline-block;"></span>
										<?else:?>
											<span class="badge badge-warning"><?=floatval($v->tardy);?></span>
										<?endif;?>

									<?endif;?>
							</td>
						<?endif;?>
						<?endforeach?>
						<td><div class="badge badge-warning"><?=$tot_tardy;?></div></td>
					</tr>
			</table>
		<?else:?>
				<div class="alert-box"> Please Select A Student to show attendance.</div>
		<?endif;?>
</div>